<template>
  <meta-detail :id="id" @finishCommit="finishCommit"></meta-detail>
</template>
<script>
import MetaDetail from "./components/MetaDetail.vue";
import { saveSkuMeta } from "@/api/product";

export default {
  components: { MetaDetail },
  data() {
    return {
      id: undefined,
    };
  },
  created() {
    this.id = this.$route.query.id;
  },
  methods: {
    finishCommit(list) {
      console.log(list);
      this.$confirm("是否要提交该元产品列表？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        const uploadList = list.map((item) => {
          const { metaType, ...rest } = item;
          return {
            ...rest,
          };
        });
        saveSkuMeta({ metaRelList: uploadList, skuId: this.id }).then(() => {
          this.$message({
            type: "success",
            message: "提交成功",
            duration: 1000,
          });
          this.$router.back();
        });
      });
    },
  },
};
</script>
<style></style>
